/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bs.views;

import com.bs.beans.Lancamento;
import java.util.ArrayList;

/**
 *
 * @author Bone
 */
public class ContaAReceberView extends javax.swing.JPanel {

    /**
     * Creates new form BancoDetalhe
     */
    public ContaAReceberView() {
        initComponents();
        contaAReceberGridController.getParametros().add(concluidoPesquisa);
        contaAReceberGridController.getParametros().add(vencimentoPesquisa);
        contaAReceberGridController.getParametros().add(entradaPesquisa);
        contaAReceberGridController.getParametros().add(contaPesquisa);
        contaAReceberGridController.getParametros().add(tipoPesquisa);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        bindingGroup = new org.jdesktop.beansbinding.BindingGroup();

        entityManager = new com.bs.persistencia.EntityManager();
        contaAReceberGridController = new com.bs.controllers.ContaAReceberGridController<com.bs.beans.Lancamento>();
        list = org.jdesktop.observablecollections.ObservableCollections.observableList(new ArrayList<Lancamento>());
        concluidoPesquisa = new com.bs.pesquisaView.PesquisaBoolean();
        entradaPesquisa = new com.bs.pesquisaView.PesquisaBoolean();
        lancamento = new com.bs.beans.Lancamento();
        tituloFormulario1 = new com.bs.extensoesSwing.TituloFormulario();
        jPanel1 = new javax.swing.JPanel();
        vencimentoPesquisa = new com.bs.pesquisaView.IntervaloData();
        jLabel1 = new javax.swing.JLabel();
        limiteRegistroField = new com.bs.extensoesSwing.CampoNumericoInteiro();
        contaPesquisa = new com.bs.pesquisaView.PesquisaObjeto();
        tipoPesquisa = new com.bs.pesquisaView.PesquisaObjeto();
        filtrarRegistroGridButton1 = new com.bs.extensoesSwing.FiltrarRegistroGridButton();
        alterarRegistroGridButton1 = new com.bs.extensoesSwing.AlterarRegistroGridButton();
        atualizarGridButton1 = new com.bs.extensoesSwing.AtualizarGridButton();
        excluirRegistroGridButton1 = new com.bs.extensoesSwing.ExcluirRegistroGridButton();
        novoRegistroGridButton1 = new com.bs.extensoesSwing.NovoRegistroGridButton();
        concluirButton = new javax.swing.JButton();
        jSeparator1 = new javax.swing.JSeparator();
        jScrollPane1 = new javax.swing.JScrollPane();
        lancamentosTable = new javax.swing.JTable();

        contaAReceberGridController.setClasse(lancamento);
        contaAReceberGridController.setEntityManager(entityManager);
        contaAReceberGridController.setLista(list);

        org.jdesktop.beansbinding.Binding binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, lancamentosTable, org.jdesktop.beansbinding.ELProperty.create("${selectedElement}"), contaAReceberGridController, org.jdesktop.beansbinding.BeanProperty.create("beanSelecionado"));
        binding.setSourceNullValue(null);
        binding.setSourceUnreadableValue(null);
        bindingGroup.addBinding(binding);
        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, lancamentosTable, org.jdesktop.beansbinding.ELProperty.create("${selectedElement.id}"), contaAReceberGridController, org.jdesktop.beansbinding.BeanProperty.create("idBeanSelecionado"));
        binding.setSourceNullValue(null);
        binding.setSourceUnreadableValue(null);
        bindingGroup.addBinding(binding);

        concluidoPesquisa.setCampo("concluido");

        entradaPesquisa.setCampo("entrada");
        entradaPesquisa.setName("Contas a receber"); // NOI18N
        entradaPesquisa.setValorCheck(true);

        setName("Contas a receber"); // NOI18N

        tituloFormulario1.setTitulo("Conta a receber");

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Filtro"));

        vencimentoPesquisa.setCampo("dataVencimento");
        vencimentoPesquisa.setLegenda("Vencimento:");

        jLabel1.setText("Limite de registros:");

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, contaAReceberGridController, org.jdesktop.beansbinding.ELProperty.create("${limiteRegistros}"), limiteRegistroField, org.jdesktop.beansbinding.BeanProperty.create("text"));
        binding.setSourceUnreadableValue(null);
        bindingGroup.addBinding(binding);

        contaPesquisa.setCampo("conta");
        contaPesquisa.setCampoPesquisa("descricao");
        contaPesquisa.setConsulta("SELECT c FROM Conta c WHERE c.descricao LIKE :parametro");
        contaPesquisa.setLegenda("Conta:");

        tipoPesquisa.setCampo("tipo");
        tipoPesquisa.setCampoPesquisa("descricao");
        tipoPesquisa.setConsulta("SELECT t FROM TipoLancamento t WHERE t.descricao LIKE :parametro");
        tipoPesquisa.setLegenda("Tipo:");

        filtrarRegistroGridButton1.setController(contaAReceberGridController);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(contaPesquisa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(vencimentoPesquisa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(limiteRegistroField, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(tipoPesquisa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(filtrarRegistroGridButton1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(filtrarRegistroGridButton1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel1)
                            .addComponent(limiteRegistroField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(vencimentoPesquisa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(contaPesquisa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(tipoPesquisa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(14, Short.MAX_VALUE))
        );

        alterarRegistroGridButton1.setController(contaAReceberGridController);

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, lancamentosTable, org.jdesktop.beansbinding.ELProperty.create("${selectedElement != null}"), alterarRegistroGridButton1, org.jdesktop.beansbinding.BeanProperty.create("enabled"));
        bindingGroup.addBinding(binding);

        atualizarGridButton1.setController(contaAReceberGridController);

        excluirRegistroGridButton1.setController(contaAReceberGridController);

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, lancamentosTable, org.jdesktop.beansbinding.ELProperty.create("${selectedElement != null}"), excluirRegistroGridButton1, org.jdesktop.beansbinding.BeanProperty.create("enabled"));
        bindingGroup.addBinding(binding);

        novoRegistroGridButton1.setController(contaAReceberGridController);

        concluirButton.setText("Concluir");

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, lancamentosTable, org.jdesktop.beansbinding.ELProperty.create("${selectedElement != null}"), concluirButton, org.jdesktop.beansbinding.BeanProperty.create("enabled"));
        bindingGroup.addBinding(binding);

        concluirButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                concluirButtonActionPerformed(evt);
            }
        });

        lancamentosTable.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
        lancamentosTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);

        org.jdesktop.swingbinding.JTableBinding jTableBinding = org.jdesktop.swingbinding.SwingBindings.createJTableBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, list, lancamentosTable);
        org.jdesktop.swingbinding.JTableBinding.ColumnBinding columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${dataVencimento}"));
        columnBinding.setColumnName("Vencimento");
        columnBinding.setColumnClass(java.util.Date.class);
        columnBinding.setEditable(false);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${pessoa.razaoSocial}"));
        columnBinding.setColumnName("Pessoa");
        columnBinding.setColumnClass(String.class);
        columnBinding.setEditable(false);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${conta.descricao}"));
        columnBinding.setColumnName("Conta");
        columnBinding.setColumnClass(String.class);
        columnBinding.setEditable(false);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${tipo.descricao}"));
        columnBinding.setColumnName("Tipo");
        columnBinding.setColumnClass(String.class);
        columnBinding.setEditable(false);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${valor}"));
        columnBinding.setColumnName("Valor");
        columnBinding.setColumnClass(java.math.BigDecimal.class);
        columnBinding.setEditable(false);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${desconto}"));
        columnBinding.setColumnName("Desconto");
        columnBinding.setColumnClass(java.math.BigDecimal.class);
        columnBinding.setEditable(false);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${juros}"));
        columnBinding.setColumnName("Juros");
        columnBinding.setColumnClass(java.math.BigDecimal.class);
        columnBinding.setEditable(false);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${total}"));
        columnBinding.setColumnName("Total");
        columnBinding.setColumnClass(java.math.BigDecimal.class);
        columnBinding.setEditable(false);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${observacao}"));
        columnBinding.setColumnName("Observacao");
        columnBinding.setColumnClass(String.class);
        columnBinding.setEditable(false);
        jTableBinding.setSourceUnreadableValue(null);
        bindingGroup.addBinding(jTableBinding);
        jTableBinding.bind();
        jScrollPane1.setViewportView(lancamentosTable);
        lancamentosTable.getColumnModel().getColumn(0).setPreferredWidth(80);
        lancamentosTable.getColumnModel().getColumn(1).setPreferredWidth(200);
        lancamentosTable.getColumnModel().getColumn(2).setPreferredWidth(150);
        lancamentosTable.getColumnModel().getColumn(3).setPreferredWidth(150);
        lancamentosTable.getColumnModel().getColumn(4).setPreferredWidth(100);
        lancamentosTable.getColumnModel().getColumn(5).setPreferredWidth(100);
        lancamentosTable.getColumnModel().getColumn(6).setPreferredWidth(100);
        lancamentosTable.getColumnModel().getColumn(7).setPreferredWidth(100);
        lancamentosTable.getColumnModel().getColumn(8).setPreferredWidth(250);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(tituloFormulario1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jSeparator1)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 722, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(concluirButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(novoRegistroGridButton1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(alterarRegistroGridButton1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(excluirRegistroGridButton1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(atualizarGridButton1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(tituloFormulario1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 170, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(alterarRegistroGridButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(atualizarGridButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(excluirRegistroGridButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(novoRegistroGridButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(concluirButton, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        bindingGroup.bind();
    }// </editor-fold>//GEN-END:initComponents

    private void concluirButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_concluirButtonActionPerformed
        contaAReceberGridController.concluir();
    }//GEN-LAST:event_concluirButtonActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private com.bs.extensoesSwing.AlterarRegistroGridButton alterarRegistroGridButton1;
    private com.bs.extensoesSwing.AtualizarGridButton atualizarGridButton1;
    private com.bs.pesquisaView.PesquisaBoolean concluidoPesquisa;
    private javax.swing.JButton concluirButton;
    private com.bs.controllers.ContaAReceberGridController<com.bs.beans.Lancamento> contaAReceberGridController;
    private com.bs.pesquisaView.PesquisaObjeto contaPesquisa;
    private com.bs.persistencia.EntityManager entityManager;
    private com.bs.pesquisaView.PesquisaBoolean entradaPesquisa;
    private com.bs.extensoesSwing.ExcluirRegistroGridButton excluirRegistroGridButton1;
    private com.bs.extensoesSwing.FiltrarRegistroGridButton filtrarRegistroGridButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JSeparator jSeparator1;
    private com.bs.beans.Lancamento lancamento;
    private javax.swing.JTable lancamentosTable;
    private com.bs.extensoesSwing.CampoNumericoInteiro limiteRegistroField;
    private java.util.List<com.bs.beans.Lancamento> list;
    private com.bs.extensoesSwing.NovoRegistroGridButton novoRegistroGridButton1;
    private com.bs.pesquisaView.PesquisaObjeto tipoPesquisa;
    private com.bs.extensoesSwing.TituloFormulario tituloFormulario1;
    private com.bs.pesquisaView.IntervaloData vencimentoPesquisa;
    private org.jdesktop.beansbinding.BindingGroup bindingGroup;
    // End of variables declaration//GEN-END:variables
}
